package com.itheima.controller;

import com.itheima.pojo.ClassOption;
import com.itheima.pojo.JobOption;
import com.itheima.pojo.Result;
import com.itheima.service.ClazzService;
import com.itheima.service.EmpService;
import com.itheima.service.StuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private EmpService empService;

    @Autowired
    private StuService stuService;

    /**
     * 员工性别分布报表
     * */
    @GetMapping("/empGenderData")
    public Result getEmpGenderReport() {
        //日志记录
        log.info("查询员工性别分布报表");

        //调用业务层方法查询员工性别分布报表内容数据
        List<Map<String, Object>> empGenderList =  empService.getEmpGenderReport();

        //将查询结果封装成Result对象并返回
        return Result.success(empGenderList);
    }

    /**
     * 员工职位人数分布表
     * */
    @GetMapping("/empJobData")
    public Result getEmpJobReport(){
        //日志记录
        log.info("查询员工职位分布报表");

        //调用业务层方法查询员工职位分布报表内容数据
        JobOption jobOption = empService.getEmpJobReport();

        return Result.success(jobOption);
    }

    /**
     * 学员学历统计
     * */
    @GetMapping("/studentDegreeData")
    public Result getStuDegreeReport(){
        //日志记录
        log.info("学员学历统计");

        //调用业务层方法查询学员学历统计内容数据
        List<Map<String, Object>> stuDegreeList = stuService.getStuDegreeReport();

        //将查询结果封装成Result对象并返回
        return Result.success(stuDegreeList);
    }

    /**
     * 班级人数统计
     * */
    @GetMapping("/studentCountData")
    public Result getStudentCountData(){
        //日志记录
        log.info("班级人数统计");

        //调用业务层方法查询班级人数统计内容数据
        ClassOption classOption = stuService.getStudentCountData();

        //将查询结果封装成Result对象并返回
        return Result.success(classOption);
    }
}
